From: Marco Trevisan (TreviƱo) Date: Wed, 27 Mar 2019 21:57:33 +0000 (+0100) Subject: magnifier: Only connect to signals when ZoomRegion is active X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~871^2^2~18 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3e0915521a9dfbaec306890ccff5b3c689fa0b40;p=gnome-shell.git magnifier: Only connect to signals when ZoomRegion is active There's no need to listen signals when the zoom region is inactive, so let's just connect/disconnect them. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/472 --- diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index a059ee98f..ba7227d67 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -754,13 +754,29 @@ var ZoomRegion = class ZoomRegion { this._pointerIdleMonitor = Meta.IdleMonitor.get_for_device(Meta.VIRTUAL_CORE_POINTER_ID); this._scrollContentsTimerId = 0; + } - Main.layoutManager.connect('monitors-changed', - this._monitorsChanged.bind(this)); - this._focusCaretTracker.connect('caret-moved', - this._updateCaret.bind(this)); - this._focusCaretTracker.connect('focus-changed', - this._updateFocus.bind(this)); + _connectSignals() { + if (this._signalConnections) + return; + + this._signalConnections = []; + let id = Main.layoutManager.connect('monitors-changed', + this._monitorsChanged.bind(this)); + this._signalConnections.push([Main.layoutManager, id]); + + id = this._focusCaretTracker.connect('caret-moved', this._updateCaret.bind(this)); + this._signalConnections.push([this._focusCaretTracker, id]); + + id = this._focusCaretTracker.connect('focus-changed', this._updateFocus.bind(this)); + this._signalConnections.push([this._focusCaretTracker, id]); + } + + _disconnectSignals() { + for (let [obj, id] of this._signalConnections) + obj.disconnect(id); + + delete this._signalConnections; } _updateScreenPosition() { @@ -824,7 +840,9 @@ var ZoomRegion = class ZoomRegion { this._updateMagViewGeometry(); this._updateCloneGeometry(); this._updateMousePosition(); + this._connectSignals(); } else { + this._disconnectSignals(); this._destroyActors(); } @@ -1574,9 +1592,6 @@ var ZoomRegion = class ZoomRegion { } _monitorsChanged() { - if (!this.isActive()) - return; - this._background.set_size(global.screen_width, global.screen_height); this._updateScreenPosition(); }